//
//  LZReportProblemsPresenter.m
//  laziz_Consumer
//
//  Created by xbn_iMac on 2016/12/26.
//  Copyright © 2016年 XBN. All rights reserved.
//

#import "LZReportProblemsPresenter.h"
#import "NetworkServiceManager.h"
#import "NSString+Additions.h"
#import "LZUserModel.h"

extern NSString *merchant;
static NSString *const kReportProblemsUrl = @"/user/feedBack";    // 问题反馈

@implementation LZReportProblemsPresenter

+ (void)reportProblemWithType:(NSString*)type andContent:(NSString*)content onSuccess:(PresenterCommonSuccess)success onFail:(PresenterCommonFail)fail {
    NSString *urlStr = COMBINATION(merchant,kReportProblemsUrl);
    
    NSMutableDictionary *params = [@{@"content":content} mutableCopy];
    
    if ([LZUserModel Instance].userToken.length > 0) {
        params[@"token"] = [LZUserModel Instance].userToken;
    }
    
    if ([LZUserModel Instance].userId.length > 0) {
        params[@"userId"] = [LZUserModel Instance].userId;
    }
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:fail]) {
            
            SAFE_BLOCK_INVOKE(success, resultData[@"data"]);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}
@end
